package com.deepseek.project.controller;

import com.deepseek.project.domain.R;
import com.deepseek.project.model.TalkInfo;
import com.deepseek.project.model.TalkInfoMessage;
import com.deepseek.project.service.ITalkInfoService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * author: hulei
 * 对话框控制层
 */
@RestController
@RequestMapping("/deepSeek")
public class TalkInfoController {

    @Resource
    private ITalkInfoService deepSeekService;

    /**
     * 查询对话框列表
     */
    @GetMapping("/talkInfoList")
    public R<List<TalkInfo>> talkInfoList() {
        return R.ok(deepSeekService.talkInfoList());
    }

    /**
     * 新建对话框
     */
    @PostMapping("/saveTalkInfo")
    public R<Integer> saveTalkInfo(@RequestBody TalkInfo talkInfo) {
        return R.ok(deepSeekService.saveTalkInfo(talkInfo));
    }

    /**
     * 更新对话框
     */
    @PostMapping("/updateTalkInfo")
    public R<Boolean> updateTalkInfo(@RequestBody TalkInfo talkInfo) {
        return R.ok(deepSeekService.updateTalkInfo(talkInfo));
    }

    /**
     * 删除对话框
     */
    @PostMapping("/deleteTalkInfo")
    public R<Boolean> deleteTalkInfo(@RequestBody TalkInfo talkInfo){
        return R.ok(deepSeekService.deleteTalkInfo(talkInfo));
    }
//======================================================================================================================
    /**
     * 保存会话消息
     */
    @PostMapping("/saveTalkInfoMessage")
    public R<Boolean> saveTalkInfoMessage(@RequestBody TalkInfoMessage talkInfoMessage) {
        return R.ok(deepSeekService.saveTalkInfoMessage(talkInfoMessage));
    }

    /**
     * 根据对话框id获取会话消息列表
     */
    @GetMapping("/getMessageListByTalkInfoId")
    public R<List<TalkInfoMessage>> getMessageListByTalkInfoId(String talkInfoId){
        return R.ok(deepSeekService.getMessageListByTalkInfoId(Integer.parseInt(talkInfoId)));
    }


//======================================================================================================================
    /**
     * webSocket心跳检测专用方法
     */
    @GetMapping("/heartBeatCheck")
    public R<String> heartBeatCheck() {
        return R.ok("heartBeatCheck");
    }
}
